package com.scoresystem.dao.proxy;

import java.sql.Connection;
import java.util.List;

import com.scoresystem.dao.IScoreDao;
import com.scoresystem.dao.impl.ScoreDaoImpl;
import com.scoresystem.model.Score;
import com.scoresystem.model.StuScore;
import com.scoresystem.utils.JdbcUtil;

public class ScoreDaoProxy implements IScoreDao {
	private IScoreDao dao=null;
	private Connection conn=null;
	public ScoreDaoProxy()throws Exception{
		conn=JdbcUtil.getInstance().getConnection();
		dao=new ScoreDaoImpl(conn);
	}
	@Override
	public List<StuScore> listAll(String stuclass, String couresename, String workname) {
		List<StuScore> list=dao.listAll(stuclass, couresename, workname);
		JdbcUtil.getInstance().free(conn);
		return list;
	}

	@Override
	public boolean insertScores(String stuclass, String coursename, String worknum, String[] stunum,
			String[] score,String[] stuname) {
		boolean bool=dao.insertScores(stuclass, coursename, worknum, stunum, score, stuname);
		JdbcUtil.getInstance().free(conn);
		return bool;
	}
	@Override
	public String getScorebyClassCourse(String stunum,String stuclass, String coursename) {
		String result=null;
		result=dao.getScorebyClassCourse(stunum,stuclass, coursename);
		JdbcUtil.getInstance().free(conn);
		return result;
	}
	@Override
	public List<Score> listscores(String stunum) {
		List<Score> list=dao.listscores(stunum);
		JdbcUtil.getInstance().free(conn);
		return list;
	}
	@Override
	public boolean modify(String stuclass, String coursename, String worknum, String stunum, String score) {
		boolean bool=dao.modify(stuclass, coursename, worknum, stunum, score);
		JdbcUtil.getInstance().free(conn);
		return bool;
	}
	@Override
	public boolean insertScore(String stuclass, String couresename, String worknum, String stunum, String score,
			String stuname) {
		boolean bool=dao.insertScore(stuclass, couresename, worknum, stunum, score, stuname);
		JdbcUtil.getInstance().free(conn);
		return bool;
	}

}
